﻿IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RA_addUser_sp]') AND type in (N'P'))
DROP PROCEDURE [dbo].[RA_addUser_sp]
go

CREATE PROCEDURE dbo.RA_addUser_sp
(
	@username		varchar(50),
	@passwordHash	varchar(50),
	@displayName	varchar(50),
	@emailAddress	varchar(255)
)
AS
	SET NOCOUNT ON
	
	declare @count int
	set @count = (select count(1) from RA_Users where username=@username)
	
	if (@count = 0)
	begin
	
		insert into RA_Users
			(username, passwordHash, displayName, emailAddress)
			values
			(@username, @passwordHash, @displayName, @emailAddress)
		
	end	